/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package model.dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import model.dao.util.MySqlDataAccessHelper;
import model.pojo.Catalogue;

/**
 *
 * @author TiOc
 */
public class CatalogueDAO 
{
    public static ArrayList<Catalogue> getCatalogue()
    {
        ArrayList<Catalogue> ds = new ArrayList<Catalogue>();
        String sql = "SELECT * FROM Catalogue As cl WHERE cl.isPublish = '1'";
        MySqlDataAccessHelper helper = new MySqlDataAccessHelper();
        helper.open();
        ResultSet rs = helper.executeQuery(sql); 
        try
        {
            while(rs.next())
            {
                Catalogue cl = new Catalogue();
                cl.setIdCatalogue(rs.getInt("idCatalogue"));
                cl.setNameCatalogue(rs.getString("nameCatalogue"));
                cl.setLink(rs.getString("link"));
                cl.setOrder(rs.getInt("order"));
                cl.setIsPublish(rs.getInt("isPublish"));
                ds.add(cl);
            }
        }
        catch(SQLException ex)
        {
            System.out.println(ex.getMessage());
        }
        helper.close();
        
        return ds;
    }
}
